/**创建活动 */
import { useState, useEffect } from 'react';
import { Button } from 'antd';
import { useHistory } from 'umi';
import ScreenTab from './Activitylist/ScreenTab';
import ScreenForm from './Activitylist/ScreenForm';
import ActivityTable from './Activitylist/ActivityTable';
import { loginApi } from '@/api/login';
import { pageConditionQueryByCreatorIdUrl } from '@/urls/url';

const CreateActivity = () => {
  const history = useHistory();
  const [params, setParams] = useState({
    activityName: '',
    queryStartDate: '',
    queryEndDate: '',
    activityStatus: [],
    isDraft: '',
    page: 1,
    pageSize: 10,
  });
  const [tableData, setTableData] = useState<any>({});
  const getData = async () => {
    const {
      data: { data },
    } = await loginApi(pageConditionQueryByCreatorIdUrl, params);
    if (data) {
      setTableData(data);
    }
  };
  useEffect(() => {
    getData();
  }, [params]);
  return (
    <div style={{ background: '#fff', padding: 24 }}>
      <ScreenTab setParams={setParams} />
      <ScreenForm setParams={setParams} />
      <Button
        type="primary"
        onClick={() => {
          history.push('/createActivity/addActivity');
        }}
        style={{ marginBottom: 10 }}
      >
        创建活动
      </Button>
      <ActivityTable
        params={params}
        setParams={setParams}
        tableData={tableData}
      />
    </div>
  );
};
export default CreateActivity;
